package com.example.sls.controller.logistics;

import com.example.sls.pojo.logistics.AnnouncementHistory;
import com.example.sls.service.intserfaces.logistics.AnnouncementHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.datetime.DateFormatter;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 公告历史记录表(AnnouncementHistory)表控制层
 *
 * @author 蓝江富
 * @since 2024-06-19 13:23:44
 */
@RestController
@RequestMapping("logistics/announcementHistory")
public class AnnouncementHistoryController {
  @Autowired
  AnnouncementHistoryService announcementHistoryService;

  @InitBinder
  public void initDateFormate(WebDataBinder dataBinder) {
    dataBinder.addCustomFormatter(new DateFormatter("yyyy-MM-dd HH:mm:ss"));
  }

  @GetMapping("queryById")
  AnnouncementHistory queryById(Integer id) {
    return announcementHistoryService.queryById(id);
  }

  @GetMapping("queryAllByLimit")
  List<AnnouncementHistory> queryAllByLimit(AnnouncementHistory announcementHistory, Integer pageSize, Integer offset) {
    return announcementHistoryService.queryAllByLimit(announcementHistory, pageSize, offset);
  }

  @GetMapping("queryAll")
  List<AnnouncementHistory> queryAllBy() {
    return announcementHistoryService.queryAllByLimit(new AnnouncementHistory(), 999999, 0);
  }

  @GetMapping("count")
  long count() {
    return announcementHistoryService.count();
  }

  @GetMapping("insert")
  int insert(AnnouncementHistory announcementHistory) {
    return announcementHistoryService.insert(announcementHistory);
  }

  @GetMapping("update")
  int update(AnnouncementHistory announcementHistory) {
    return announcementHistoryService.update(announcementHistory);
  }

  @GetMapping("deleteById")
  int deleteById(Integer id) {
    return announcementHistoryService.deleteById(id);
  }
}

